<?php

namespace App\Http\Controllers;

use App\Http\Resources\Param;
use App\ParamType;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Cache;

class ParamsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index(Request $reqeust)
    {
        // 缓存所有参数
        return Param::collection($this->getAllParams());
    }

    protected function getAllParams()
    {
        $params = Cache::rememberForever('params', function () {
            return ParamType::with('params')->get();
        });
        return $params;
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param \Illuminate\Http\Request $request
     * @return Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param \App\Param $param
     * @return Response
     */
    public function show(Param $param)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param \App\Param $param
     * @return Response
     */
    public function edit(Param $param)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param \Illuminate\Http\Request $request
     * @param \App\Param $param
     * @return Response
     */
    public function update(Request $request, Param $param)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param \App\Param $param
     * @return Response
     */
    public function destroy(Param $param)
    {
        //
    }
}
